<template>
  <dv-border-box-7 id="third-left-three-chart">
    <!-- <div class="third-right-tittle">生产统计</div> -->
    <div id="thirdLeftThreeChart"></div>
  </dv-border-box-7>
</template>

<script>
import * as echarts from "echarts";
import Axios from "axios";
export default {
  name: "thirdLeftThreeChart",

  data() {
    return {
      ProductionData: {
        x: [100, 80, 90, 100],
        // y:[1.3,1.5,1.7,1.1,0.6,0.7,0.8]
      },
    };
  },
  methods: {
     UpdateData() {
      var _this = this;
      var chartDom = document.getElementById("thirdLeftThreeChart");
      var myChart = echarts.init(chartDom);
      var option;
      var url = this.$baseUrl + "statistics/one-quarter-product";
       Axios.get(url).then((response) => (_this.ProductionData.x= Object.values(response.data)));
      option = {
        title: {
          text: "季生产统计",
          textStyle: {
            color: "white",
          },
          left: "center",
        },
        tooltip: {},

        legend: {
          top: "10%",
          textStyle: {
            color: "white",
          },
        },
        xAxis: [
          {
            type: "category",
            data: ["第一季度","第二季度","第三季度","第四季度"],
            axisPointer: {
              type: "shadow",
            },
            axisLabel: {
              textStyle: {
                color: "white",
              },
            },
          },
        ],
        yAxis: [
          {
            type: "value",
            name: "数量",
          
            
            axisLabel: {
              formatter: "{value} 个",
              textStyle: {
                color: "white",
              },
            },
          },
          // {
          //   type: "value",
          //   name: "不良率",
          //   min: 0,
          //   max: 2,
          //   interval: 0.5,
          //   axisLabel: {
          //     formatter: "{value} %",
          //      textStyle: {
          //   color: "white",
          // },
          //   },
          // },
        ],
        series: [
          {
            name: "数量(个)",
            type: "bar",
            tooltip: {
              valueFormatter: function (value) {
                return value + " 个";
              },
            },
            data: this.ProductionData.x,
            colorBy:"data"
          },

          // {
          //   name: "不良率",
          //   type: "line",
          //   yAxisIndex: 1,
          //   smooth: true,
          //   tooltip: {
          //     valueFormatter: function (value) {
          //       return value + " %";
          //     },
          //   },
          //   data:this.ProductionData.y,
          // },
        ],
      };

      option && myChart.setOption(option);
      	setTimeout(() => {
					this.UpdateData()
				}, 1000);
    },
  },

  mounted() {
     const { UpdateData } = this;

     this.UpdateData();

  },
};
</script>

<style lang="less">
#third-left-three-chart {
  width: 25%;
  height: 100%;
  background-color: rgba(6, 30, 93, 0.5);
  border-top: 2px solid rgba(1, 153, 209, 0.5);
  box-sizing: border-box;
  margin: 10px;
  float: left;
  // .third-right-tittle{
  //   font-size: 20px;
  //   display: flex;
  //   justify-content: center;
  //   align-items: center;
  // }
  #thirdLeftThreeChart {
    width: 100%;
    height: 100%;
  }
}
</style>

